package com.jinzecloud.fiction.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.jinzecloud.fiction.bean.TbAdmin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.jinzecloud.fiction.bean.TbUser;
import com.jinzecloud.fiction.service.TbUserService;
import com.jinzecloud.fiction.utils.PageUtils;
import com.jinzecloud.fiction.utils.R;



/**
 * 用户表
 *
 * @author ??
 * @email 1971240051@qq.com
 * @date 2023-10-19 19:38:04
 */
@RestController
@RequestMapping("fiction/tbuser")
public class TbUserController {
    @Autowired
    private TbUserService tbUserService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("fiction:tbuser:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tbUserService.queryPage(params);

        return R.ok().put("page", page);
    }

    @RequestMapping("/getUserList")
    public R getUserList(){
        List<TbUser> list = tbUserService.getUserList();
//        List<Object> tbUsers = new ArrayList<>();
//        tbUsers.add(list);
        return R.ok().put("data", list);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{usId}")
    //@RequiresPermissions("fiction:tbuser:info")
    public R info(@PathVariable("usId") Integer usId){
		TbUser tbUser = tbUserService.getById(usId);

        return R.ok().put("tbUser", tbUser);
    }

    /**
     * 修改状态
     * @param tbUser
     * @return
     */
    @RequestMapping("/upStatus")
    //@RequiresPermissions("fiction:tbadmin:update")
    public R upStatus(@RequestBody TbUser tbUser){
        tbUserService.upStatus(tbUser);

        return R.ok();
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("fiction:tbuser:save")
    public R save(@RequestBody TbUser tbUser){
		tbUserService.saveTbUser(tbUser);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("fiction:tbuser:update")
    public R update(@RequestBody TbUser tbUser){
		tbUserService.updateTbUserById(tbUser);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("fiction:tbuser:delete")
    public R delete(@RequestBody Integer[] usIds){
		tbUserService.removeByIds(Arrays.asList(usIds));

        return R.ok();
    }

}
